/**
 * object test3
 * date : 2014. 10
 * writer : me
 */
	array = new Array();
	
function init(){
	document.getElementById("btn").onclick = val;
	document.getElementById("listBtn").onclick = showList;
}

function Score(mid, kor,eng){
	
		this.mid = mid;
		this.kor = kor;
		this.eng= eng;
		this.tot = 0;
		this.avg = 0;
		this.compute = function(){
			this.tot = this.kor + this.eng;
			this.avg = this.tot/2;
		}
		
		this.getTot = function(){ return this.tot;}
		this.getAvg = function(){ return this.avg;}
		
}

function val() {
	
	var frm = document.frm;
	score = new Score(frm.mid.value, Number(frm.kor.value), Number(frm.eng.value));

	score.compute();
	frm.tot.value = score.getTot();
	frm.avg.value = score.getAvg();
	array.push(score);
}

function showList() {
	var list = document.frm;
	list.list.value = "";

	list.list.value += "아이디" +"\t"+ "국어" +"\t"+ "영어" +"\t"+
	"총점" +"\t"+ "평균"+"\n";	
	for(i = 0; i< array.length; i++){
		list.list.value += array[i].mid +"\t"+ array[i].kor +"\t"+ array[i].eng +"\t"+
		array[i].getTot() +"\t"+ array[i].getAvg()+"\n";		
	}
}


